import 'dart:io';
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'
    show BMFMapSDK, BMF_COORD_TYPE;
import 'package:flutter_baidu_mapapi_map/flutter_baidu_mapapi_map.dart';
import 'package:flutter_displaymode/flutter_displaymode.dart';
import 'package:fluwx/fluwx.dart';

class MainService {
  init() {
    setDisplayMode();
    setWechatSdk();
    setBaiDuMapSdk();
  }

  static MainService get instance => MainService();

  //启动高刷模式
  void setDisplayMode() async {
    try {
      var modes = await FlutterDisplayMode.supported;
      await FlutterDisplayMode.setPreferredMode(modes.last);
      // ignore: empty_catches
    } catch (e) {}
  }

  //初始化微信sdk
  setWechatSdk() {
    Fluwx fluwx = Fluwx();
    fluwx.registerApi(
        appId: "wx765e1f4f06ff6b4d",
        universalLink: "https://www.liaojianzhushou.com/app/");
  }

  setBaiDuMapSdk() {
    /// 设置用户是否同意SDK隐私协议
    BMFMapSDK.setAgreePrivacy(true);

    // 百度地图sdk初始化鉴权
    if (Platform.isIOS) {
      BMFMapSDK.setApiKeyAndCoordType(
          'VPxlWbglOvGEKqKzNaQ4NuG68zyxGyZp', BMF_COORD_TYPE.BD09LL);
    } else if (Platform.isAndroid) {
      BMFAndroidVersion.initAndroidVersion();
      BMFMapSDK.setCoordType(BMF_COORD_TYPE.BD09LL);
    }
  }
}
